home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / hardware / code.lua next >
Encoding:
Text File  |  2005-07-16  |  3.9 KB  |  121 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky03.ogg")
  8.     local pokus = getRestartCount()
  9.  
  10.  
  11.     -- -------------------------------------------------------------
  12.     local function prog_init_room()
  13.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  14.  
  15.         if pokus == 1 then
  16.             room.uvod = 0
  17.         elseif random(100) < 80 then
  18.             room.uvod = 0
  19.         else
  20.             room.uvod = 1
  21.         end
  22.         room.hlaska = random(1000) + 500
  23.         room.oldwamp = WAmp
  24.         room.oldwper = WPer
  25.         room.mluveni = 0
  26.         room.nudise = 0
  27.         room.nepas = 0
  28.  
  29.         return function()
  30.             if room.mluveni ~= 0 then
  31.                 wamp = random(4) + 4
  32.                 wper = random(4) + 1
  33.             else
  34.                 wamp = room.oldwamp
  35.                 wper = room.oldwper
  36.             end
  37.             if isReady(small) and isReady(big) and no_dialog() then
  38.                 if room.hlaska > 0 then
  39.                     room.hlaska = room.hlaska - 1
  40.                 end
  41.                 if room.uvod > 2 then
  42.                     room.uvod = room.uvod - 1
  43.                 end
  44.                 if room.uvod == 0 then
  45.                     if random(100) < 30 then
  46.                         room.uvod = random(100) + 20
  47.                     else
  48.                         room.uvod = 1
  49.                     end
  50.                     if random(100) < 30 then
  51.                         addv(random(20) + 5, "pz-v-zaskladanej")
  52.                     else
  53.                         adddel(random(20))
  54.                     end
  55.                     if random(100) < 40 then
  56.                         addm(random(8) + 3, "pz-m-co")
  57.                         addv(random(4), "pz-v-klice"..(random(2) + 1))
  58.                     else
  59.                         addv(random(8) + 3, "pz-v-co"..(random(2) + 1))
  60.                         addm(random(4), "pz-m-spoje"..(random(3) + 1))
  61.                     end
  62.                 elseif room.uvod == 2 then
  63.                     room.uvod = 1
  64.                     addm(8, "pz-m-vylez")
  65.                     addv(10, "pz-v-dat")
  66.                 elseif room.hlaska == 0 then
  67.                     room.hlaska = -1
  68.                     addm(20, "pz-m-pocitace")
  69.                     planDialogSet(random(20) + 30, "pz-x-pocitac", 5, room, "mluveni")
  70.                 elseif room.nudise == 0 and small.pohyby >= small.trpelivost and big.Y <= 8 then
  71.                     addv(20, "pz-v-hej")
  72.                     addm(0, "pz-m-nech")
  73.                     room.nudise = 1
  74.                 elseif room.nepas == 0 and (k1.Y > 5 and k1.Y < 20 and k1.dir == dir_no or k2.Y > 5 and k2.Y < 20 and k2.dir == dir_no or k3.Y > 5 and k3.Y < 20 and k3.dir == dir_no) then
  75.                     room.nepas = 1
  76.                     addm(10, "pz-m-nepasuje")
  77.                 end
  78.             end
  79.         end
  80.     end
  81.  
  82.     -- -------------------------------------------------------------
  83.     local function prog_init_small()
  84.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  85.  
  86.         small.pohyby = 0
  87.         small.trpelivost = 300 + random(700)
  88.  
  89.         return function()
  90.             if level_isNewRound() and small.dir ~= dir_no then
  91.                 small.pohyby = small.pohyby + 1
  92.             end
  93.         end
  94.     end
  95.  
  96.     -- --------------------
  97.     local update_table = {}
  98.     local subinit
  99.     subinit = prog_init_room()
  100.     if subinit then
  101.         table.insert(update_table, subinit)
  102.     end
  103.     subinit = prog_init_small()
  104.     if subinit then
  105.         table.insert(update_table, subinit)
  106.     end
  107.     return update_table
  108. end
  109. local update_table = prog_init()
  110.  
  111.  
  112. -- -----------------------------------------------------------------
  113. -- Update
  114. -- -----------------------------------------------------------------
  115. function prog_update()
  116.     for key, subupdate in pairs(update_table) do
  117.         subupdate()
  118.     end
  119. end
  120.  
  121.